home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / DHTML - Date and Time / dynamic-countdown-2.izs < prev    next >
Text File  |  2005-08-31  |  9KB  |  216 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Dynamic Countdown Script II
  4. <!/TITLE>
  5.  
  6. <!BROWSER>FF1+ IE5+ Opr7+<!/BROWSER>
  7.  
  8. <!DESCRIPTION>Version 2 of the Dynamic countdown script is accurate to the second. This allows you to count down to a particular event that's time sensitive (and not just day).
  9. <!/DESCRIPTION> 
  10.  
  11. <!CATEGORY>date and time<!/CATEGORY>
  12.  
  13. <!SCRIPT>
  14. <!-- START OF SCRIPT -->
  15. <script language="JavaScript1.2">
  16.  
  17. //Dynamic countdown Script II- ⌐ Dynamic Drive (www.dynamicdrive.com)
  18. //Support for hour minutes and seconds added by Chuck Winrich (winrich@babson.edu) on 12-12-2001
  19. //For full source code, 100's more DHTML scripts, visit http://www.dynamicdrive.com
  20.  
  21. function setcountdown(theyear,themonth,theday,thehour,themin,thesec){
  22. yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec
  23. }
  24.  
  25. //////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////
  26.  
  27. //STEP 1: Configure the countdown-to date, in the format year, month, day, hour(0=midnight,23=11pm), minutes, seconds:
  28. setcountdown(2004,12,07,18,30,00)
  29.  
  30. //STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
  31. var occasion="Bulls vs Lakers game"
  32. var message_on_occasion="Go Chicago Bulls!"
  33.  
  34. //STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
  35. var countdownwidth='520px'
  36. var countdownheight='35px'
  37. var countdownbgcolor='lightyellow'
  38. var opentags='<font face="Verdana"><small>'
  39. var closetags='</small></font>'
  40.  
  41. //////////DO NOT EDIT PAST THIS LINE//////////////////
  42.  
  43. var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
  44. var crosscount=''
  45.  
  46. function start_countdown(){
  47. if (document.layers)
  48. document.countdownnsmain.visibility="show"
  49. else if (document.all||document.getElementById)
  50. crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
  51. countdown()
  52. }
  53.  
  54. if (document.all||document.getElementById)
  55. document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')
  56.  
  57. window.onload=start_countdown
  58.  
  59.  
  60. function countdown(){
  61. var today=new Date()
  62. var todayy=today.getYear()
  63. if (todayy < 1000)
  64. todayy+=1900
  65. var todaym=today.getMonth()
  66. var todayd=today.getDate()
  67. var todayh=today.getHours()
  68. var todaymin=today.getMinutes()
  69. var todaysec=today.getSeconds()
  70. var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
  71. futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec
  72. dd=Date.parse(futurestring)-Date.parse(todaystring)
  73. dday=Math.floor(dd/(60*60*1000*24)*1)
  74. dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
  75. dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
  76. dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
  77. //if on day of occasion
  78. if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
  79. if (document.layers){
  80. document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
  81. document.countdownnsmain.document.countdownnssub.document.close()
  82. }
  83. else if (document.all||document.getElementById)
  84. crosscount.innerHTML=opentags+message_on_occasion+closetags
  85. return
  86. }
  87. //if passed day of occasion
  88. else if (dday<=-1){
  89. if (document.layers){
  90. document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
  91. document.countdownnsmain.document.countdownnssub.document.close()
  92. }
  93. else if (document.all||document.getElementById)
  94. crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
  95. return
  96. }
  97. //else, if not yet
  98. else{
  99. if (document.layers){
  100. document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
  101. document.countdownnsmain.document.countdownnssub.document.close()
  102. }
  103. else if (document.all||document.getElementById)
  104. crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
  105. }
  106. setTimeout("countdown()",1000)
  107. }
  108. </script>
  109.  
  110. <ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>
  111. <!-- END OF SCRIPT -->
  112. <!/SCRIPT>
  113.  
  114. <!PREVIEW>
  115. <!-- START OF SCRIPT -->
  116. <script language="JavaScript1.2">
  117.  
  118. //Dynamic countdown Script II- ⌐ Dynamic Drive (www.dynamicdrive.com)
  119. //Support for hour minutes and seconds added by Chuck Winrich (winrich@babson.edu) on 12-12-2001
  120. //For full source code, 100's more DHTML scripts, visit http://www.dynamicdrive.com
  121.  
  122. function setcountdown(theyear,themonth,theday,thehour,themin,thesec){
  123. yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec
  124. }
  125.  
  126. //////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////
  127.  
  128. //STEP 1: Configure the countdown-to date, in the format year, month, day, hour(0=midnight,23=11pm), minutes, seconds:
  129. setcountdown(2004,12,07,18,30,00)
  130.  
  131. //STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
  132. var occasion="Bulls vs Lakers game"
  133. var message_on_occasion="Go Chicago Bulls!"
  134.  
  135. //STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
  136. var countdownwidth='520px'
  137. var countdownheight='35px'
  138. var countdownbgcolor='lightyellow'
  139. var opentags='<font face="Verdana"><small>'
  140. var closetags='</small></font>'
  141.  
  142. //////////DO NOT EDIT PAST THIS LINE//////////////////
  143.  
  144. var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
  145. var crosscount=''
  146.  
  147. function start_countdown(){
  148. if (document.layers)
  149. document.countdownnsmain.visibility="show"
  150. else if (document.all||document.getElementById)
  151. crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
  152. countdown()
  153. }
  154.  
  155. if (document.all||document.getElementById)
  156. document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')
  157.  
  158. window.onload=start_countdown
  159.  
  160.  
  161. function countdown(){
  162. var today=new Date()
  163. var todayy=today.getYear()
  164. if (todayy < 1000)
  165. todayy+=1900
  166. var todaym=today.getMonth()
  167. var todayd=today.getDate()
  168. var todayh=today.getHours()
  169. var todaymin=today.getMinutes()
  170. var todaysec=today.getSeconds()
  171. var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
  172. futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec
  173. dd=Date.parse(futurestring)-Date.parse(todaystring)
  174. dday=Math.floor(dd/(60*60*1000*24)*1)
  175. dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
  176. dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
  177. dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
  178. //if on day of occasion
  179. if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
  180. if (document.layers){
  181. document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
  182. document.countdownnsmain.document.countdownnssub.document.close()
  183. }
  184. else if (document.all||document.getElementById)
  185. crosscount.innerHTML=opentags+message_on_occasion+closetags
  186. return
  187. }
  188. //if passed day of occasion
  189. else if (dday<=-1){
  190. if (document.layers){
  191. document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
  192. document.countdownnsmain.document.countdownnssub.document.close()
  193. }
  194. else if (document.all||document.getElementById)
  195. crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
  196. return
  197. }
  198. //else, if not yet
  199. else{
  200. if (document.layers){
  201. document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
  202. document.countdownnsmain.document.countdownnssub.document.close()
  203. }
  204. else if (document.all||document.getElementById)
  205. crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
  206. }
  207. setTimeout("countdown()",1000)
  208. }
  209. </script>
  210.  
  211. <ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>
  212.  
  213. <!-- END OF SCRIPT -->
  214. <!/PREVIEW>
  215.  
  216. <!RELATED>NONE<!/RELATED>